package com.wangp.mywrite.inwork.mapstruct;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/***
 * @author wangpeng
 * @since 2022-09-01  16:43
 *
 * <p>
 * 该类会生成一个 IUserMapperImpl 类
 * </p>
 */
// public class IUserMapperImpl implements IUserMapper {
//     public UserReproducer copyUser(final User user) {
//         if (user == null) {
//             return null;
//         }
//         final UserReproducer userReproducer = new UserReproducer();
//         userReproducer.setUserName(user.getUname());
//         userReproducer.setId(user.getId());
//         userReproducer.setName(user.getName());
//         userReproducer.setAge(user.getAge());
//         return userReproducer;
//     }
// }

@Mapper
public interface IUserMapper {

    IUserMapper INSTANCE = Mappers.getMapper(IUserMapper.class);

    @Mapping(target = "userName",source = "user.uname")
    UserReproducer copyUser(User user);
}
